package bsh.dyn;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * An abstract {@link Parameter} that holds reference types
 * 
 * @author takeshi
 */
public abstract class AbstractReferenceParameter implements Parameter {

    @SuppressWarnings("unchecked")
    private static final Set<Class<?>> PRIMITIVE_WRAPPERS = Collections.unmodifiableSet(new HashSet<Class<?>>(Arrays.asList(Boolean.class,
            Byte.class, Character.class, Short.class, Integer.class, Long.class, Float.class, Double.class, BigDecimal.class)));

    /**
     * {@inheritDoc}
     */
    public boolean isPrimitive() {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public boolean isSuperClassOf(Parameter another) {
        return this.getJavaType().isAssignableFrom(another.getJavaType());
    }

    /**
     * {@inheritDoc}
     */
    public boolean isPrimitiveWrapper() {
        return PRIMITIVE_WRAPPERS.contains(getJavaType());
    }

}
